package com.zzq.my.jetpacks.jectpackapp.bean

import android.os.Parcel
import android.os.Parcelable

class Person() :Parcelable {
    var name:String = ""
    var age:Int = 0

    constructor(parcel: Parcel) : this() {
        name = parcel.readString().toString()
        age = parcel.readInt()
    }

    override fun describeContents(): Int =0

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(name)
        dest.writeInt(age)
    }

    companion object CREATOR : Parcelable.Creator<Person> {
        override fun createFromParcel(parcel: Parcel): Person {
            val person = Person()
            person.name = parcel.readString()?:""
            person.age = parcel.readInt()?:0
            return person
        }

        override fun newArray(size: Int): Array<Person?> {
            return arrayOfNulls(size)
        }
    }
}